<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Welcome extends CI_Controller {

	/**
	 * Index Page for this controller.
	 *
	 * Maps to the following URL
	 * 		http://example.com/index.php/welcome
	 *	- or -
	 * 		http://example.com/index.php/welcome/index
	 *	- or -
	 * Since this controller is set as the default controller in
	 * config/routes.php, it's displayed at http://example.com/
	 *
	 * So any other public methods not prefixed with an underscore will
	 * map to /index.php/welcome/<method_name>
	 * @see http://codeigniter.com/user_guide/general/urls.html
	 */
	public function index()
	{
        
        $this->load->database();
		$query = $this->db->query('SELECT * FROM coach where status=1 order by id desc limit 0,10');

		$coachlist = $query->result();
 
		foreach ($coachlist as $row)
		{
		    $thumb = $row->thumb;
		    if($thumb==''){
		    	$thumb = 'http://xunlianri.com/images/icon/user_big.png';
 		    }
 		    $row->thumb = $thumb;
 		    $stype = $row->sporttypes;
 		    $stypearr = explode(",",$stype);

  		    if($stypearr[1]=='1'){
  		    	$sname = '健身';
   		    }
  		    if($stypearr[1]=='2'){
  		    	$sname = '羽毛球';
   		    }
  		    if($stypearr[1]=='3'){
  		    	$sname = '网球';
   		    }
  		    if($stypearr[1]=='4'){
  		    	$sname = '高尔夫';
   		    }
  		    if($stypearr[1]=='5'){
  		    	$sname = '游泳';
   		    }
  		    if($stypearr[1]=='6'){
  		    	$sname = '瑜伽';
   		    }
  		    if($stypearr[1]=='7'){
  		    	$sname = '跑步';
   		    }

   		    $row->sname = $sname;


 		}
 
        $data['coachlist'] = $coachlist;


        //目前member暂时只有coach
        $member_id = '0';
        if(!isset($_COOKIE['member_id'])){
              
 		}else{
 			if($_COOKIE['member_id']!=''){
 			    $member_id = $_COOKIE['member_id'];
 			}
  		}

        $data['member_id'] = $member_id;

 
		$this->load->view('welcome_message',$data);
	}
}
